#ifndef APINETWORK_H
#define APINETWORK_H

#include <QObject>
#include <QHostAddress>
#include <map>
#include "packet.h"

class								Network;

class apiNetwork : public QObject
{
	Q_OBJECT

public:
	apiNetwork(Network *network, QObject *parent = 0);
	~apiNetwork();

private:
	Network							*_network;
	
public:
	quint16							connectTo(const std::string &, const std::string &);
	void							removeClient(quint16);

	bool							isInside(quint16 id);
	bool							isInside(QHostAddress& ip);

	QHostAddress 					getIp(quint16);
	quint16							getId(QHostAddress &);

	void							sendToTcp(Packet& pkg, quint16 id = 0);
	void							sendToUdp(Packet& pkg, quint16 id = 0);

public slots:
	void							handleConnect(QHostAddress &);
	void							handleDisconnect(QHostAddress &);

signals:
	void							connected(QHostAddress &);
	void							disconnected(QHostAddress &);
};

#endif // APINETWORK_H
